<?php
    get_header();
    
?>
    <!-- banner图 -->
    <div class="banner">
        <div class="swiper-container banner swiper-banner">
            <div class="swiper-wrapper">
                <?php
                    //分类5: 首页->banner
                    query_posts('showposts=5&cat=5');
                    while ( have_posts()) {
                        the_post();
                ?>
                <div class="swiper-slide banner-slide">
                    <a href="<?php the_permalink(); ?>">
                        <span><?php the_title(); ?></span>
                        <span class="hide-img" style="display: none;"><?php the_post_thumbnail( 'full' ); ?></span>
                    </a>
                </div>
                <?php 
                    }
                    wp_reset_query();
                ?>
            </div>
            <div class="banner-pagination"></div>
        </div>
    </div>
    <!-- /banner图 -->

    <!-- 列表模块 -->
    <div class="main-container">
        <div class="wrap">
            <div class="floor clearfix">
                <!-- 新闻聚焦 -->
                <div class="news-mod">
                    <div class="head-type01">
                        <h2>新闻聚焦</h2>
                        <a href="/news">更多></a>
                    </div>
                    <div class="news-list-con clearfix"> 
                        <?php
                            //分类6: 新闻聚焦
                            query_posts('showposts=1&cat=6');
                            while(have_posts()) {
                                the_post();
                        ?>
                        <dl>
                            <dt>
                                <a href="<?php the_permalink(); ?>" title=""><?php the_post_thumbnail(array(348, 300)); ?></a>
                            </dt>
                            <dd>
                                <a href="<?php the_permalink(); ?>">
                                    <p><?php the_title(); ?></p>
                                </a>
                            </dd>
                        </dl>
                        <?php
                            }
                            wp_reset_query();
                        ?>
                        <div class="news-list">
                            <div class="first">
                                <?php
                                    query_posts('showposts=1&offset=1&cat=6');
                                    while(have_posts()) {
                                        the_post();
                                ?>
                                <a href="<?php the_permalink(); ?>"><?php the_title(); ?></a>
                                <p><?php the_excerpt(); ?></p>
                                <?php
                                    }
                                    wp_reset_query();
                                ?>
                            </div>
                            <ul class="normal">
                                <?php
                                    query_posts('showposts=6&offset=2&cat=6');
                                    while(have_posts()) {
                                        the_post();
                                ?>
                                <li class="clearfix">
                                    <a href="<?php the_permalink(); ?>"><?php the_title(); ?></a>
                                    <span><?php the_time('m-d'); ?></span>
                                </li>
                                <?php
                                    }
                                    wp_reset_query();
                                ?>
                            </ul>
                        </div>
                    </div>
                </div>
                <!-- /新闻聚焦 -->
                <!-- 专题 -->
                <div class="subject-mod">
                    <div class="head-type02">
                        <h2>专题</h2>
                        <a href="/topic">更多></a>
                    </div>
                    <div class="swiper-container">
                        <div class="subject-list-con swiper-wrapper">
                            <?php
                                //分类7: 专题
                                query_posts(array(
                                    'showposts'=>5,
                                    'category__in' => 7
                                ));
                                while(have_posts()) {
                                    the_post();
                            ?>
                            <a class="swiper-slide" href="<?php echo site_url() . get_post_meta($post->ID, "url")[0]; ?>">
                                <dl>
                                    <dt>
                                        <?php the_post_thumbnail(array(260, 185)); ?>
                                    </dt>
                                    <dd>
                                        <p><?php the_title(); ?></p>
                                    </dd>
                                </dl>
                            </a>
                            <?php
                                }
                                wp_reset_query();
                            ?>
                        </div>
                    </div>
                </div>
                <!-- /专题 -->
            </div>

            <div class="floor clearfix">
                <div class="ac-mod clearfix">
                    <!-- 基础介绍 -->
                    <ul class="ac-nav">
                        <li>
                            <a href="/about/index">本会简介</a>
                        </li>
                        <li>
                            <a href="/about/organization">组织机构</a>
                        </li>
                        <li>
                            <a href="/about/department">工作部门</a>
                        </li>
                        <li>
                            <a href="/about/association">章程</a>
                        </li>
                        <li>
                            <a href="/about/system">制度法规</a>
                        </li>
                    </ul>
                    <!-- /基础介绍 -->
                    <!-- 佛讯动态 -->
                    <div class="ac-list-con">
                        <div class="head-type01">
                            <h2>佛讯动态</h2>
                            <a href="/buddhism-news">更多></a>
                        </div>
                        <div class="list">
                            <?php
                                //分类8: 佛讯动态
                                query_posts('showposts=3&cat=8');
                                while(have_posts()) {
                                    the_post();
                            ?>
                            <a href="<?php the_permalink(); ?>">
                                <dl class="clearfix">
                                    <dt>
                                        <?php the_post_thumbnail(array(170, 76)); ?>
                                    </dt>
                                    <dd>
                                        <h3><?php the_title(); ?></h3>
                                        <p><?php the_excerpt(); ?></p>
                                    </dd>
                                </dl>
                            </a>
                            <?php
                                }
                                wp_reset_query();
                            ?>
                        </div>
                    </div>
                    <!-- /佛讯动态 -->
                </div>
                <!-- 信息公告 -->
                <div class="notice-mod">
                    <div class="head-type02">
                        <h2>信息公告</h2>
                        <a href="/announcement">更多></a>
                    </div>
                    <ul>
                        <?php
                            //分类9: 信息公告
                            query_posts('showposts=8&cat=9');
                            while(have_posts()) {
                                the_post();
                        ?>
                        <li>
                            <i></i>
                            <a href="<?php the_permalink(); ?>"><?php the_title(); ?></a>
                            <span><?php the_time('m-d'); ?></span>
                        </li>
                        <?php
                            }
                            wp_reset_query();
                        ?>
                    </ul>
                </div>
                <!-- /信息公告 -->
            </div>
                                
            <div class="floor clearfix">
                <!-- 视频 -->
                <div class="video-mod">
                    <div class="head-type01">
                        <h2>视频</h2>
                        <a href="/video">更多></a>
                    </div>
                    <div class="video-list-con clearfix">
                        <?php
                            //分类10: 视频
                            query_posts('showposts=3&cat=10');
                            while(have_posts()) {
                                the_post();
                        ?>
                        <a href="<?php the_permalink(); ?>">
                            <dl>
                                <dt>
                                    <?php the_post_thumbnail(array(243, 140)); ?>
                                    <span></span>
                                </dt>
                                <dd>
                                    <p><?php the_title(); ?></p>
                                </dd>
                            </dl>
                        </a>
                        <?php
                            }
                            wp_reset_query();
                        ?>
                    </div>
                </div>
                <!-- /视频 -->
                <!-- 期刊简报 -->
                <div class="journal-mod">
                    <div class="head-type02">
                        <h2>
                            <span class="active">期刊</span>|
                            <span>简报</span>
                        </h2>
                        <a href="/issue">更多></a>
                    </div>
                    <ul class="list on">
                        <?php
                            //分类11: 期刊
                            query_posts('showposts=2&cat=11');
                            while(have_posts()) {
                                the_post();
                        ?>
                        <li>
                            <a href="<?php the_permalink(); ?>">
                                <?php the_post_thumbnail(array(126, 163)); ?>
                                <span><?php the_title(); ?></span>
                            </a>
                        </li>
                        <?php
                            }
                            wp_reset_query();
                        ?>
                    </ul>
                    <ul class="list">
                        <?php
                            //分类12: 简报
                            query_posts('showposts=2&cat=12');
                            while(have_posts()) {
                                the_post();
                        ?>
                        <li>
                            <a href="<?php the_permalink(); ?>">
                                <?php the_post_thumbnail(array(126, 163)); ?>
                                <span><?php the_title(); ?></span>
                            </a>
                        </li>
                        <?php
                            }
                            wp_reset_query();
                        ?>
                    </ul>
                </div>
                <!-- /期刊简报 -->
            </div>

            <div class="floor">
                <div class="tem-mod clearfix">
                    <div class="tem-pic"></div>
                    <div class="tem-list">
                        <div class="head-type02" id="temList">
                            <h2>
                                <span class="active">福州</span>|
                                <span>厦门</span>|
                                <span>漳州</span>|
                                <span>泉州</span>|
                                <span>三明</span>|
                                <span>莆田</span>|
                                <span>龙岩</span>|
                                <span>南平</span>|
                                <span>宁德</span>|
                                <span>平潭综合实验区</span>
                            </h2>
                            <a href="/fj-temple/fuzhou-temple">更多></a>
                        </div>
                        <div class="tem-slide-con">
                            <div class="swiper-container swiper-tem">
                                <div class="swiper-wrapper">
                                    <?php
                                        //分类14-23是福建省各地的寺庙编号
                                        for ($i = 14; $i < 24; $i++) {
                                            query_posts('showposts=5&cat='.$i);
                                    ?>
                                    <div class="swiper-slide tem-slide">
                                        <div class="item clearfix">
                                            <?php
                                                while(have_posts()) {
                                                    the_post();
                                            ?>
                                            <a href="<?php the_permalink(); ?>">
                                            <?php the_post_thumbnail(array(170, 146)); ?>
                                                <span><?php the_title(); ?></span>
                                            </a>
                                            <?php
                                                }
                                                wp_reset_query();
                                            ?>
                                        </div>
                                    </div>
                                    <?php
                                        }
                                    ?>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>

            <div class="floor">
                <div class="friend-mod">
                    <div class="head-type01">
                        <h2>友情链接</h2>
                        <a href="/link">更多></a>
                    </div>
                    <ul>
                    <?php wp_list_bookmarks('orderby=rand&show_images=0&title_li=&categorize=0&before=<li><i></i>&after=</li>&category=32,33,34,35,36,37'); ?>
                    </ul>
                </div>
            </div>

            <div class="floor">
                <div class="sponsor-mod">
                    <h2>赞助单位</h2>
                    <ul class="clearfix">
                        <?php wp_list_bookmarks('orderby=rand&show_images=1&title_li=&categorize=0&before=<li>&after=</li>&category=44'); ?>
                    </ul>
                </div>
            </div>
        </div>
    </div>
<?php
    get_footer();
?>
<script>
    $(function () {
        $('.ac-list-con p').each(function() {
            if ($(this).text() === '') {
                $(this).remove();
            }
        });
        $('.banner').find('.swiper-slide a').each(function() {
            var src = $(this).find('.hide-img').find('img').attr('src');
            $(this).css('background', 'url(' + src + ') center no-repeat');
        });
        var $temList = $('#temList').find('span');
        var mySwiper = $(".swiper-banner").swiper({
            loop: true,
            autoplay: 5000,
            loop: true,
            loopAdditionalSlides: 3,
            pagination: ".banner-pagination",
            paginationClickable: true,
            autoplayDisableOnInteraction: false
            //其他设置
        });

        var mySwiper02 = $(".swiper-tem").swiper({
            loop: true,
            autoplay: 5000,
            loop: true,
            autoplayDisableOnInteraction: false,
            onSlideChangeStart: function (swiper) {
                if (swiper.activeIndex == 11) {
                    $temList.eq(0).addClass('active').siblings().removeClass('active');
                } else if (swiper.activeIndex == 0) {
                    $temList.eq(9).addClass('active').siblings().removeClass('active');
                } else {
                    $temList.eq(swiper.activeIndex - 1).addClass('active').siblings().removeClass('active');
                }

            }
        });
        if ($('.subject-mod .swiper-wrapper').children('a').length > 2) {
            new Swiper('.subject-mod .swiper-container', {
                slidesPerGroup: 2,
                slidesPerView: 2,
                autoplay: 5000,
                loop: true,
                mode: 'vertical',
                roundLength: true,
                onlyExternal: true,
            });
        }

        $temList.on('click', function () {
            var _index = $(this).index();
            $(this).addClass('active').siblings().removeClass('active');
            mySwiper02.swipeTo(_index, 1000, true);
        });

        //简报
        $('.journal-mod .head-type02 span').click(function() {
            var index = $(this).index();
            var moreLink = index === 0 ? '/issue' : '/briefing';
            $(this).addClass('active').siblings().removeClass('active');
            $(this).parent().parent().siblings('.list').removeClass('on').eq(index).addClass('on');
            $(this).parent().next().attr('href', moreLink);
        })
    });
</script>
</body>
</html>